﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:SkGui.Controls">
    
    <local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>

    <Style x:Key="EllipseStyle" TargetType="Ellipse" >
        <Style.Setters>
            <Setter Property="Width" Value="25"/>
            <Setter Property="Height" Value="25"/>
            <Setter Property="Fill" >
                <Setter.Value>
                    <RadialGradientBrush>
                        <GradientStop Color="#00C7C7C7" Offset="1"/>
                        <GradientStop Color="#B5D0D0D0" Offset="0.12"/>
                    </RadialGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="RenderTransform">
                <Setter.Value>
                    <ScaleTransform 
                        ScaleX="0" ScaleY="0"
                        CenterX="12.5" CenterY="12.5"/>
                </Setter.Value>
            </Setter>
        </Style.Setters>
    </Style>   

    <Style TargetType="local:ProgressIndicator">
        <Style.Setters>
            <Setter Property="Height" Value="80"/>
            <Setter Property="Width" Value="80"/>
            <Setter Property="ElementStoryboard">
                <Setter.Value>
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="1"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.5" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="1"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.5" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="local:ProgressIndicator">
                        <Grid Visibility="{TemplateBinding IsRunning, Converter={StaticResource BoolToVisibilityConverter}}">
                            <Canvas 
                                x:Name="PART_Canvas" 
                                SnapsToDevicePixels="True"
                                Width="{TemplateBinding Width}"
                                Height="{TemplateBinding Height}">
                                <Ellipse Style="{StaticResource EllipseStyle}"/>
                                <Ellipse Style="{StaticResource EllipseStyle}"/>
                                <Ellipse Style="{StaticResource EllipseStyle}"/>
                                <Ellipse Style="{StaticResource EllipseStyle}"/>
                                <Ellipse Style="{StaticResource EllipseStyle}"/>
                                <Ellipse Style="{StaticResource EllipseStyle}"/>
                                <Ellipse Style="{StaticResource EllipseStyle}"/>
                                <Ellipse Style="{StaticResource EllipseStyle}"/>
                            </Canvas>
                            <TextBlock 
                                Name="LoadingTextBlock"
                                Text="Loading..." 
								Foreground="LightGray"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"/>
                            <TextBlock
                                Name="ProgressTextBlock"
                                Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsIndeterminate" Value="True">
                                <Setter Property="Visibility" TargetName="ProgressTextBlock" Value="Hidden"/>
                            </Trigger>
                            <Trigger Property="IsIndeterminate" Value="False">
                                <Setter Property="Visibility" TargetName="LoadingTextBlock" Value="Hidden"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style.Setters>
    </Style>
</ResourceDictionary>
